#define ElemType int

typedef struct ListNode List_Node;

#include "common.h"

double findMaxAverage(int* nums, int numsSize, int k);

int main()
{
	int nums[6] = { 1, 12, -5, -6, 50, 3 };
	findMaxAverage(nums, 6, 4);
	return 0;
}

double findMaxAverage(int* nums, int numsSize, int k)
{
	int sum = 0;
	for (int i = 0; i < k; i++)
		sum += nums[i];
	int max = sum;

	for (int i = k, lo = i - k; i < numsSize; i++, lo++) {
		sum += nums[i];
		sum -= nums[lo];
		if (sum > max)
			max = sum;
	}

	return (double)max / k;
}
